﻿using System.Diagnostics.Contracts;
using System.Windows.Forms;

namespace System
{
    public static class ExceptionExtentions
    {
        [Diagnostics.DebuggerStepThrough]
        public static void ComfirmThrow(this Exception e, string Message)
        {
            Contract.Requires(e != null, "Exception == null");
            Contract.Requires(Message != null, "Message == null");
            Contract.Requires(Message != "");

            var result = MessageBox.Show(Message + "\r\nИгнорировать?", "Exception", MessageBoxButtons.YesNo, MessageBoxIcon.Error,
                                         MessageBoxDefaultButton.Button2, MessageBoxOptions.ServiceNotification);
            if(result == DialogResult.Yes) return;
            throw e;
        }

        public static void ComfirmThrow(this Exception e) { e.ComfirmThrow(e.Message); }

    }
}
